/*
 Most of these codes are not made from my work. Some of them are copy from Cydia & Winterboard by saurik.
 Some codes are dupricate from Appbackup by Scott Wallace. 
 */
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <CoreGraphics/CGGeometry.h>
// define inline subfunction...
#define _string(str)	[[NSBundle mainBundle] localizedStringForKey: str value: "" table: nil]
#define _fontsize(size)	[[UIFont systemFontOfSize: size] retain];

// return size in format
NSString *SizeString(double size) {
	bool negative = size < 0;
	if (negative)
		size = -size;

	unsigned power = 0;
	while (size > 1024) {
		size /= 1024;
		++power;
	}
	static const char *powers_[] = {"B", "kB", "MB", "GB"};
	return [NSString stringWithFormat:@"%s%.1f %s", (negative ? "-" : ""), size, powers_[power]];
}

// Class define 

@interface OfflineMaps : UIApplication<
    UITableViewDataSource,
    UITableViewDelegate
>{
	UIWindow			*window;
	UITableView			*tableview;
	UINavigationBar		*navbar;
	NSMutableDictionary	*currentData; // include all Data in used, such as Map , Route , Bookmark
	/*
	{
		currentDate include:
			current<Maps/Routes/Bookmarks>{
				Title in string
				Path in string
				Size in string
			}
	}
	 */
	NSMutableArray		*screen; //include all data which is displaying...
	/*
	{
		screen include:
			sections<Maps/Routes/Bookmarks>{
				item{
					Title in string
					Path in string
					Size in string
					Badge in string
					Method in string // or maybe only link method ...
					Description {
						Routes:
							From_place in string
							To_place in string
							XML_Data in XMLparser
						Bookmarks:
							category in string
							XML_Data in XMLparser
					}
				}
			}
	}
	 */
}
- (void) imosinit();

@end
// Class source code
@implementation OfflineMaps;
- (void) dealloc(){
	[window release];
	[navbar release];
	[tableview release];
	[currentData release];
	[screen release];
	[super dealloc];
}
- (void) imosinit(){
	// Making List ...
}
- (void) applicationWillTerminate:(UIApplication *)application {
	//just terminate ...
}
- (bool *) tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
	return [tableView isEditing];
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero] autorelease];
    NSMutableDictionary *theme = [themesArray_ objectAtIndex:[indexPath row]];
    cell.text = [theme objectForKey:@"Name"];
    cell.hidesAccessoryWhenEditing = NO;
    NSNumber *active = [theme objectForKey:@"Active"];
    BOOL inactive = active == nil || ![active boolValue];
    cell.accessoryType = inactive ? UITableViewCellAccessoryNone : UITableViewCellAccessoryCheckmark;
    return cell;
}
- (void)applicationDidFinishLaunching: ( id ) unused {
	// project init at here 
	imosinit();
	// View init
	
	window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]applicationFrame]];
	[window makeKeyAndVisible];
	navbar = [[UINavigationBar alloc] initWithFrame:[UINavigationBar defaultSize]];
	[window addSubview: navbar];
	
	tableview = [[UITableView alloc] initWithFrame: "?" ];
	[window addSubview: view];
}

@end
// program start point
int main(int argc, char *argv[])
{
	NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
	int retVal = UIApplicationMain(argc, argv, @"OfflineMaps", @"OfflineMaps");
	[pool release];
	return retVal;
}